#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
int fx[][2] = {0, 1, 0, -1, 1, 0, -1, 0, 1, 1, -1, -1, 1, -1, -1, 1};
int n, m, k;
int a[21][21];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    freopen("A.in", "r", stdin);
    while (cin >> n >> m >> k) {
        memset(a, 0, sizeof(a));//C-Style
        //fill(a[0], a[0] + (21 * 21), 0) ;//C++ Style
        while (k--) {
            int x, y;
            cin >> x >> y;
            a[x][y] = 9;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i][j] == 9)continue;
                int cnt = 0;
                for (int x = 0; x < 8; x++) {
                    int nx = i + fx[x][0];
                    int ny = j + fx[x][1];
                    if (nx < 0 || nx >= n || ny < 0 || ny >= m)continue;
                    if (a[nx][ny] == 9)++cnt;
                }
                a[i][j] = cnt;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i][j] == 9)cout << '*';
                else
                    cout << a[i][j];
            }
            cout << endl;
        }
        cout << endl;

    }
    return 0;
}
